package cn.flying.cloud.message.core.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.flying.cloud.base.mail.exception.MsgException;
import cn.flying.cloud.message.core.enums.SendType;
import cn.flying.cloud.message.model.MessageRequest;

/**
 * 短信服务类
 *
 * @author: admin
 * @date: 2025年03月27日 16:18
 * @version: 1.0
 */
@Service
public class MessageService extends AbstractMessageSenderService {

    /**
     * @param request
     * @return
     */
    public void sendSms(MessageRequest request) {
        send(request, SendType.SMS, false);
    }


    /**
     * 简单文本邮件
     *
     * @param request
     * @throws MsgException
     */
    @Transactional(rollbackFor = Exception.class)
    public void sendSimpleMail(MessageRequest request) throws MsgException {
        send(request, SendType.EMAIL, false);
    }

    /**
     * html邮件
     *
     * @param request
     */
    public void sendHtmlMail(MessageRequest request) {
        send(request, SendType.EMAIL, true);
    }
}
